﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class DeptRequisitionW
    {
        int deptReqID;
        string deptID;
        string startDate;
        string endDate;
        int collectionPointDetailID;
        int retrievedBy;
        string retrievedDate;
        int collectedBy;
        int disbursedBy;

        [DataMember]
        public int DeptReqID
        {
            get { return deptReqID; }
            set { deptReqID = value; }
        }

        [DataMember]
        public string DeptID
        {
            get { return deptID; }
            set { deptID = value; }
        }

        [DataMember]
        public string StartDate
        {
            get { return startDate; }
            set { startDate = value; }
        }

        [DataMember]
        public string EndDate
        {
            get { return endDate; }
            set { endDate = value; }
        }

        [DataMember]
        public int CollectionPointDetailID
        {
            get { return collectionPointDetailID; }
            set { collectionPointDetailID = value; }
        }

        [DataMember]
        public int RetrievedBy
        {
            get { return retrievedBy; }
            set { retrievedBy = value; }
        }

        [DataMember]
        public string RetrievedDate
        {
            get { return retrievedDate; }
            set { retrievedDate = value; }
        }

        [DataMember]
        public int CollectedBy
        {
            get { return collectedBy; }
            set { collectedBy = value; }
        }

        [DataMember]
        public int DisbursedBy
        {
            get { return disbursedBy; }
            set { disbursedBy = value; }
        }

        public static DeptRequisitionW convert(DeptRequisition deptRequisition)
        {
            DeptRequisitionW u = new DeptRequisitionW();

            u.DeptReqID = deptRequisition.DeptReqID;
            u.DeptID = deptRequisition.DeptID;
            u.StartDate = deptRequisition.StartDate.GetValueOrDefault().ToString();
            u.EndDate = deptRequisition.EndDate.GetValueOrDefault().ToString();
            u.CollectionPointDetailID = deptRequisition.CollectionPointDetailID.GetValueOrDefault();
            u.RetrievedBy = deptRequisition.RetrievedBy.GetValueOrDefault();
            u.RetrievedDate = deptRequisition.RetrievedDate.GetValueOrDefault().ToString();
            u.CollectedBy = deptRequisition.CollectedBy.GetValueOrDefault();
            u.DisbursedBy = deptRequisition.DisbursedBy.GetValueOrDefault();

            return u;
        }

        public static List<DeptRequisitionW> convertList(List<DeptRequisition> list)
        {
            List<DeptRequisitionW> listW = new List<DeptRequisitionW>();

            foreach (DeptRequisition x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }

    }
}